{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "x = np.linspace(-5, 10, 40)\n",
    "y = (x - 2.5) ** 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 计算梯度值\n",
    "def grad(val):\n",
    "    return 2 * (val - 2.5)\n",
    "\n",
    "\n",
    "def fun_val(val):\n",
    "    return (val - 2.5) ** 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 初始化\n",
    "# w = 0\n",
    "# lr = 0.1  # 学习率；步长\n",
    "\n",
    "# --------------------------------------\n",
    "# w = -4\n",
    "# lr = 0.1  # 学习率；步长\n",
    "\n",
    "# -------------------------------\n",
    "# w = 0\n",
    "# lr = 1  # 学习率；步长\n",
    "#--------------------------\n",
    "w = 0\n",
    "lr = 0.8  # 学习率；步长\n",
    "\n",
    "#--------------------------\n",
    "# w = -4\n",
    "# lr = 0.99  # 学习率；步长\n",
    "\n",
    "# -----------------------------\n",
    "# w = -4\n",
    "# lr = 1.1  # 学习率；步长"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "总共多少次 11\n"
     ]
    }
   ],
   "source": [
    "tatal_fun = []\n",
    "w_val = []  # 记录所有的位置\n",
    "cnt = 0  # 记录次数\n",
    "while True:\n",
    "    w_val.append(w)  # 记录下每次的x的值\n",
    "\n",
    "    # 当x等于某个值时，对应的函数值\n",
    "    fun_value = fun_val(w)\n",
    "    tatal_fun.append(fun_value)  # 记录下每次的y的值\n",
    "\n",
    "    grad_val = grad(w)  # 计算梯度\n",
    "\n",
    "    # 沿着梯度反方向更新\n",
    "    # 下一次x的位置=当前-梯度\n",
    "    w = w - lr * grad_val\n",
    "    cnt += 1\n",
    "    if (np.abs(grad_val) < 10 ** (-6)) or (cnt > 10):\n",
    "        break\n",
    "print(\"总共多少次\", cnt)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAD4CAYAAAD1jb0+AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAApbUlEQVR4nO3dd3zV5d3/8dcngyRASAhkkcleYRqW4hZHFVGrggOpo1Sr1rb2Vlp/d7W1Wttaq3dttRQHCqLUUamrIoqKssLeJIQsCCRhJCQh+/r9cU4khACHJCfXGZ/n48Hj5BxCzhvBdy6u7/W9LjHGoJRSyvsE2A6glFKqdbTAlVLKS2mBK6WUl9ICV0opL6UFrpRSXiqoI9+sZ8+eJjU1tSPfUimlvN6aNWtKjDHRzV/v0AJPTU0lIyOjI99SKaW8nojktvS6TqEopZSX0gJXSikvpQWulFJeSgtcKaW8lBa4Ukp5KS1wpZTyUlrgSinlpbyiwL/OLObvS7Nsx1BKqTNWWVPHb/6zhdwDFe3+tb2iwJdllvDMpzspKquyHUUppc7IBxsLeeWbHIqOVLf71/aKAp86Jom6BsO/1hTYjqKUUmdkwao8+sV0JT2le7t/ba8o8D7RXRnXO4q3VufT0KAnCCmlvMOOfUdYl3eYaWOSEJF2//peUeAAN41NJu9gJcuzD9iOopRSLlmwKo9OgQFcNzrRLV/fawr88rQ4IsKCWbAqz3YUpZQ6raraet5bt4dLh8YS1aWTW97Dawo8NDiQa0cl8OmW/RysqLEdRymlTumTzfsoPVrLTWOT3fYeXlPg4JhGqalv4N21ejFTKeXZFqzKI6VHZyb06eG29/CqAh8YF87o5EgWrMrDGL2YqZTyTNnF5azcfZC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v2i0i8MaZQROKBovb4oj4/Aj8ZY8wmY0yMMSbVGJOK4y/r6I4u79MRkcuBh4GrjTGVtvM4efyB1uL4rvwSsM0Y84ztPM0ZY35pjEl0/t2bBnzuYeWN8/+FfBEZ6HzpYmCrxUjN5QHjRaSz88/7YjzoImszi4AZzo9nAO+3xxf1+RG4D3geCAEWO/+lsMIYc7fNQMaYOhG5D/gvxw603mIzUwvOAaYDm0RkvfO1XznPcVWuux+Y7/xGnQ3cbjnPd4wxK0XkbWAtjunFdXjALfUisgC4AOgpIgXAo8BTwEIRuRPHN54b2uW9PONf5Eoppc6U306hKKWUt9MCV0opL6UFrpRSXkoLXCmlvJQWuFJKeSktcKWU8lJa4Eop5aX+P0BzUIN5tOnSAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(x, y)\n",
    "plt.plot(w_val, tatal_fun, color='r', marker='o')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
